<template>
	<camera></camera>
	<button type="default" @click="takePhoto">拍照</button>
	<view class="afterPhoto">
		<image :src="src" mode=""></image>
		<button class="upload" v-show="btnShow" @click="queding">确定</button>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				src:'',
				btnShow:false,
			}
		},
		methods: {
			takePhoto(){
						  const ctx = uni.createCameraContext();
						              ctx.takePhoto({
						                  quality: 'high',
						                  success: (res) => {
											  console.log(res)
						                      this.src = res.tempImagePath
										  // console.log("222",this.src)
											  if(this.src!='')this.btnShow=true
						                  },
						              });
			},
			queding(){
						uni.saveImageToPhotosAlbum({
							filePath: this.src,
							success: function (res) {
								// console.log('save success');
								// console.log(res);
							}
						});
					}
		}
	}
</script>

<style>
camera{
	width: 750rpx;
	height: 750rpx;
}
image{
	width: 375rpx;
	height: 375rpx;
}
.afterPhoto{
	display: flex;
	align-items: center;
}
.upload{
	width: 200rpx;
	height: 80rpx;
}
</style>
